<template>
    <div>
        <div class="title">
            <div class="back" @click="$router.back()">
                <span @click="change"> <img src="../assets/img/fanhui.png" alt=""></span>
            </div>
            <div class="gamename" v-if="gameDetail != null">{{ gameDetail.name }}</div>
            <div class="more"><span>&#8230;</span></div>
        </div>
        <div class="swiper">
            <div class="swiper-container-category">
                <div class="swiper-wrapper">
                    <div class="swiper-slide">
                        <video src="https://s1.sonkwo.hk/medium/910135728720663/file/81675/a1_batch.mp4"
                            poster="https://s1.sonkwo.hk/medium/910135728720663/file/81675/a1_batch.mp4?spm=a2c4g.11186623.2.1.yjOb8V&amp;x-oss-process=video/snapshot,t_1000,f_jpg,m_fast"
                            controls="" preload="metadata" id="video1"></video>
                    </div>
                    <div class="swiper-slide">
                        <video src="https://s1.sonkwo.hk/medium/910135728720663/file/81676/a2_batch.mp4"
                            poster="https://s1.sonkwo.hk/medium/910135728720663/file/81676/a2_batch.mp4?spm=a2c4g.11186623.2.1.yjOb8V&amp;x-oss-process=video/snapshot,t_1000,f_jpg,m_fast"
                            controls="" preload="metadata" id="video0"></video>
                    </div>
                    <div class="swiper-slide">
                        <img src="https://s1.sonkwo.hk/medium/910135728720663/file/48236/5.jpg " alt=" ">
                    </div>
                    <div class="swiper-slide">
                        <img src="https://s1.sonkwo.hk/medium/910135728720663/file/48235/4.jpg " alt=" ">
                    </div>
                    <div class="swiper-slide">
                        <img src="https://s1.sonkwo.hk/medium/910135728720663/file/48234/3.jpg " alt=" ">
                    </div>
                    <div class="swiper-slide">
                        <img src="https://s1.sonkwo.hk/medium/910135728720663/file/48236/5.jpg " alt=" ">
                    </div>
                    <div class="swiper-slide">
                        <img src="https://s1.sonkwo.hk/medium/910135728720663/file/48236/5.jpg " alt=" ">
                    </div>
                </div>
            </div>
        </div>
        <div class="gameinfo">
            <div class="gameinfodetail">
                <div class="Chinesename">
                    <p v-if="gameDetail != null">{{ gameDetail.name }}</p>
                </div>
                <div class="Englishname">
                    <p v-if="gameDetail != null">{{ gameDetail.english }}</p>
                </div>
                <div class="money" v-if="gameDetail">
                    <span>￥{{ gameDetail.price }}</span> <span>{{ gameDetail.zk }}</span> <span>￥{{ gameDetail.oldprice
                    }}</span>
                </div>
            </div>
        </div>
        <div class="activation">
            <div class="method">
                <p>激活方式&nbsp;&nbsp;&nbsp;<span>Steam</span>平台安装激活。</p>
            </div>
            <div class="onsell">
                <!-- <VueCtkDateTimePicker label="请选择时间" :locale="`zn-ch`" v-model="yourValue" /> -->
                <p><span>促销</span>&nbsp;&nbsp;&nbsp;共有4张优惠券</p>
                <span>></span>
            </div>
        </div>
        <div class="version">
            <div class="versionitem" @click="version = true">
                <p>版本&nbsp;&nbsp;&nbsp;此游戏有2个版本</p>
                <span>></span>
            </div>
            <div class="dlc" @click="dlc = true">
                <p>DLC&nbsp;&nbsp;&nbsp;此游戏有1个DLC</p>
                <span>></span>
            </div>
        </div>
        <div class="version">
            <div class="versionitem" @click="sell = true">
                <p>发售详情</p>
                <span>></span>
            </div>
            <div class="dlc" @click="configuration = true">
                <p>配置详情</p>
                <span>></span>
            </div>
        </div>
        <div class="introduce">
            <p>游戏介绍</p>
            <div class="content">
                <p>传说中的 Stylish Action 《Devil May Cry 5》与 “DMC5 - 可游玩角色 'Vergil'” 成套登场！</p>
                <p>超越现实的真实感。 <br>
                    “最强”、“革新”、“王道” ── 三款不同的战斗风格。 <br>
                    互相竞争、炫示的联机游玩功能。</p>
                <p>动作游戏的所有快感都集结于此！</p>
                <p>※本套装内的 “DMC5 - 可游玩角色'Vergil'” 与另外单独贩售的商品的内容相同，请小心重复购买。 <br>
                    ※已购入《Devil May Cry 5》的玩家请小心重复购买。</p>
            </div>
        </div>
        <div class="bottom" style="height: 50px
        ;"></div>

        <div>
            <van-goods-action style="border: 1px solid #cccccc;">
                <router-link to="/shopCar">
                    <van-goods-action-icon style="border-right: 1px solid #cccccc;" icon="cart-o" text="购物车" />
                </router-link>
                <van-goods-action-icon icon="like-o" text="收藏" />
                <van-goods-action-button @click="addCar" type="warning" :text="inCar ? '已在购物车' : '加入购物车'" />
                <van-goods-action-button type="danger" text="立即购买" />
            </van-goods-action>
        </div>

        <van-popup class="hide" v-model="version" closeable close-icon="close" position="bottom"
            :style="{ height: '92.5%' }">
            <p>此游戏的其他版本</p>
            <div class="content">
                <p>维吉尔豪华版</p>
                <p>￥137.0</p>
            </div>
        </van-popup>

        <van-popup class="hide" v-model="dlc" closeable close-icon="close" position="bottom" :style="{ height: '92.5%' }">
            <p>此游戏的DLC</p>
            <div class="content">
                <p>鬼泣5：可游玩角色"维吉尔"</p>
                <p>￥24.0</p>
            </div>
        </van-popup>
        <van-popup class="hide" v-model="dlc" closeable close-icon="close" position="bottom" :style="{ height: '92.5%' }">
            <p>此游戏的DLC</p>
            <div class="content">
                <p>鬼泣5：可游玩角色"维吉尔"</p>
                <p>￥24.0</p>
            </div>
        </van-popup>
        <van-popup class="hide" v-model="sell" closeable close-icon="close" position="bottom" :style="{ height: '92.5%' }">
            <p>发售详情</p>
            <div class="content" style="background-color: #fff
            ;">
                <div class="items">
                    <div class="item">
                        <p class="fir">开发商</p>
                        <div class="itemdetail">
                            <p>CAPCOM Co., Ltd.</p>
                        </div>
                    </div>
                    <div class="item">
                        <p class="fir">发行商</p>
                        <div class="itemdetail">
                            <p>Capcom</p>
                        </div>
                    </div>
                    <div class="item">
                        <p class="fir">发行日期</p>
                        <div class="itemdetail">
                            <p style="background-color: #fff;">2021-11-24</p>
                        </div>
                    </div>
                    <div class="item">
                        <p class="fir">游戏语言</p>
                        <div class="itemdetail">
                            <p>简体中文</p>
                            <p>繁体中文</p>
                            <p>英文</p>
                        </div>
                    </div>
                    <div class="item">
                        <p class="fir">下载方式</p>
                        <div class="itemdetail">
                            <p>第三方平台</p>
                        </div>
                    </div>
                    <div class="item">
                        <p class="fir">支持系统</p>
                        <div class="itemdetail">
                            <p>Win</p>
                        </div>
                    </div>
                </div>
            </div>
        </van-popup>
        <van-popup class="hide" v-model="configuration" closeable close-icon="close" position="bottom"
            :style="{ height: '92.5%' }">
            <p>配置详情</p>
            <div class="configuration">
                <div class="platform">
                    <span>Windows</span>
                </div>
            </div>
            <van-tabs v-model="active" animated>
                <van-tab :title="'最低配置 '">
                    <div class="lowconfiguration">
                        <div class="item">
                            <div class="left">操作系统</div>
                            <div class="right">WINDOWS® 7, 8.1, 10 (64-BIT Required)</div>
                        </div>
                        <div class="item">
                            <div class="left">内存</div>
                            <div class="right">8 GB RAM</div>
                        </div>
                        <div class="item">
                            <div class="left">处理器</div>
                            <div class="right">Intel® Core™ i5-4460, AMD FX™-6300, or better</div>
                        </div>
                        <div class="item">
                            <div class="left">DirectX 版本</div>
                            <div class="right">11</div>
                        </div>
                        <div class="item">
                            <div class="left">图形</div>
                            <div class="right">NVIDIA® GeForce® GTX 760 or AMD Radeon™ R7 260x with 2GB Video RAM, or better
                            </div>
                        </div>
                        <div class="item">
                            <div class="left">硬盘</div>
                            <div class="right">需要 35 GB 可用空间</div>
                        </div>
                        <div class="item">
                            <div class="left">其他</div>
                            <div class="right">*Xinput support Controllers recommended *Internet connection required for
                                game activation. (Network connectivity uses Steam® developed by Valve® Corporation.)</div>
                        </div>
                        <div class="bottom" style="height: 20px
                        ;"></div>
                    </div>
                </van-tab>
                <van-tab :title="'推荐配置 '">
                    <div class="lowconfiguration">
                        <div class="item">
                            <div class="left">操作系统</div>
                            <div class="right">WINDOWS® 7, 8.1, 10 (64-BIT Required)</div>
                        </div>
                        <div class="item">
                            <div class="left">内存</div>
                            <div class="right">8 GB RAM</div>
                        </div>
                        <div class="item">
                            <div class="left">处理器</div>
                            <div class="right">Intel® Core™ i7-3770, AMD FX™-9590, or better</div>
                        </div>
                        <div class="item">
                            <div class="left">DirectX 版本</div>
                            <div class="right">11</div>
                        </div>
                        <div class="item">
                            <div class="left">图形</div>
                            <div class="right">NVIDIA® GeForce® GTX 1060 with 6GB VRAM, AMD Radeon™ RX 480 with 8GB VRAM, or
                                better
                            </div>
                        </div>
                        <div class="item">
                            <div class="left">硬盘</div>
                            <div class="right">需要 35 GB 可用空间</div>
                        </div>
                        <div class="item">
                            <div class="left">其他</div>
                            <div class="right">*Xinput support Controllers recommended *Internet connection required for
                                game activation. (Network connectivity uses Steam® developed by Valve® Corporation.)</div>
                        </div>
                        <div class="bottom" style="height: 20px
                        ;"></div>
                    </div>
                </van-tab>
            </van-tabs>
        </van-popup>
    </div>
</template>


<style lang="scss" scoped>
.lowconfiguration {
    padding: 0 12px;
    display: flex;
    flex-direction: column;
    margin-top: 12px;
    border: 1px solid #f5f5f5;

    .item {
        display: flex;
        align-items: center;
        border: 1px solid #e5e5e5;

        &:nth-child(even) {
            background-color: #f5f5f5;
        }

        .left {
            text-align: center;
            width: 75px;
            font-size: 16px;
            padding: 15px 0;
        }

        .right {
            // text-align: center;
            flex: 1;
            font-size: 16px;
            margin-left: 10px;
        }
    }
}

.configuration {
    margin: 15px 0;
    margin-top: 20 px;
    padding: 0px 12px;



    .platform {
        span {
            padding: 10px;
            background-color: #ffede8;
            border: 1px solid #ff5722;
            border-radius: 5px;
            color: #ff5722;
        }
    }
}

.hide {
    .content {
        .items {
            display: flex;
            flex-direction: column;

            .item {
                .fir {
                    width: 70px;
                }

                .itemdetail {
                    p {
                        padding: 5px 15px;
                        margin-right: 5px;
                        background-color: #f5f5f5;
                        border-radius: 5px;
                        margin-top: 5px;
                    }

                    margin-left: 30px;
                    flex: 1;
                    display: flex;
                    flex-wrap: wrap;
                    align-items: center;

                }

                display: flex;
                justify-content: space-between;
                flex-wrap: wrap;

                p {
                    border: none;
                    font-weight: normal;
                    color: #666666;
                }
            }
        }

        padding: 0 10px;
        display: flex;
        justify-content: space-between;
        width: 90%;
        margin: 0 auto;
        background-color: #f5f5f5;
        margin-top: 20px;
        border-radius: 5px;

        p {
            &:nth-child(1) {
                font-weight: bold;
            }

            &:nth-child(2) {
                color: #ff5722;
            }
        }
    }

    p {
        padding: 10px 10px;
        border-bottom: 1px solid #f5f5f5;
        font-size: 16px;


    }
}

.van-goods-action {
    // bottom: 15px;
    height: 40px;

    .van-button {
        margin-right: 0px;
        border-radius: 0px;
    }
}

.introduce {
    p {
        font-size: 18px;
        font-weight: bold;
    }


    width: 94%;
    margin: 0 auto;
    margin-top: 20px;

    .content {
        p {
            margin-bottom: 20px;
            font-size: 16px;
            font-weight: normal;
        }
    }

}

.version {
    padding-top: 10px;

    .versionitem {
        display: flex;
        justify-content: space-between;
        align-items: center;

        span {
            font-size: 20px;
            color: #cccccc;
        }

        p {
            padding: 10px 0;
        }

        padding: 5px 10px;
        border-bottom: 1px solid #f5f5f5;
    }

    .dlc {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 10px;

        span {
            font-size: 20px;
            color: #cccccc;
        }

    }
}

.activation {

    margin: 0 auto;

    padding-top: 20px;

    .method {
        padding: 0 10px;


        border-bottom: 1px solid#f5f5f5;

        p {
            font-size: 15px;
            padding: 10px 0;

            span {
                color: #0e90d2;
            }
        }
    }

    .onsell {
        span {
            font-size: 20px;
            color: #cccccc;
        }

        justify-content: space-between;
        align-items: center;
        display: flex;

        padding: 0 10px;

        // border-bottom: 1px#f5f5f5;
        p {
            font-size: 15px;
            padding: 10px 0;

            span {
                border: 1px solid #ff5722;
                border-radius: 3px;
                font-size: 12px;
                color: #ff5722;
                padding: 1px 3px;
            }
        }
    }
}

.gameinfo {
    width: 94%;
    margin: 0 auto;

    .gameinfodetail {
        .Chinesename {
            padding: 5px 0;

            p {
                font-size: 16px;
                font-weight: 700;
            }

        }

        .Englishname {
            padding: 5px 0;

            p {
                font-size: 12px;
                color: #666666;
            }

        }

        .money {
            span {
                &:nth-child(1) {
                    color: #ff5722;
                    font-weight: 700;
                    font-size: 15px;
                }

                &:nth-child(2) {
                    color: #ff5722;
                    font-size: 12px;
                    border: 1px solid #ff5722;
                    border-radius: 4px;
                    margin-left: 10px;
                }

                &:nth-child(3) {
                    color: #999999;
                    font-size: 12px;
                    margin-left: 10px;
                }
            }
        }


        margin: 0 auto;

        display: flex;
        flex-direction: column;


    }
}

.swiper {
    margin-top: 40px;
    overflow: hidden;
    position: relative;
    z-index: 3;

    .swiper-slide {
        img {
            width: 100%;
            height: 100%;

        }

        video {
            width: 100%;
            height: 100%;
        }
    }

}

.title {
    // width: 375px;
    position: fixed;
    display: flex;
    background-color: #333333;
    width: 100%;
    height: 50px;
    line-height: 50px;
    padding: 0 12px;
    color: #cccccc;
    justify-content: space-between;
    box-sizing: border-box;
    z-index: 4;
    top: 0;

    .back {
        display: flex;
        align-items: center;

        span {
            font-size: 16px;

            img {
                width: 16px;
                height: 16px;
            }
        }
    }

    .gamename {
        flex: 1;
        text-align: center;
        font-size: 17px;
    }

    .more {
        transform: rotate(90deg);

        span {
            font-size: 17px;
        }
    }



}
</style>
<script>
import Swiper from "swiper";
// import VueCtkDateTimePicker from 'vue-ctk-date-time-picker';
import { getTopGame } from '../api/homeView'
import { Toast } from "vant";
export default {
    components: {
        // VueCtkDateTimePicker
    },
    data() {
        return {
            yourValue: '',
            version: false,//显示隐藏选项卡
            dlc: false,//显示隐藏选项卡
            sell: false,//显示隐藏选项卡
            configuration: false,//显示隐藏选项卡
            active: 0,//显示隐藏选项卡
            gameDetail: null,//游戏详情
            inCar: false,//是否在购物车
        }
    },
    props: ['carList'],
    methods: {
        // vuex改变组件显示
        change() {
            this.$store.commit('change', true)
        }, getTopGame() {
            // 获取游戏列表
            getTopGame().then(data => {
                for (var i in data) {
                    if (data[i].name == this.$route.query.name) {
                        this.gameDetail = data[i]
                        return
                    }
                }
            })
        }, addCar() {
            // 加入购物车，是否登录
            if (window.localStorage.getItem('token') == undefined) {
                Toast('请先登录，再加入购物车')
                this.$router.push('/userLogin')
                return
            }
            else {
                Toast('已加入购物车')
                let itemName = this.$route.query.name
                // 根据购物车列表来判断是否存在购物车里面
                let res = this.carList.some(function (item) {
                    return item == itemName
                })
                if (!res) {
                    // 不存在的话，加入购物车
                    Toast('已加入购物车')
                    this.$emit('addCar', this.$route.query.name)
                    this.inCar = true
                    res = true
                    return
                }
                if (this.inCar) {
                    // 存在的话，不可以加入
                    Toast('已在购物车,请勿重复添加')
                }
                // 无论是否，只要点击过后，改变状态
                this.inCar = res
            }


        }, checkInCar() {
            // 通过app的购物车列表查询是否存在购物车里面，正常来说放在localStorage(数据库)里面，避免app更新购物车列表
            let itemName = this.$route.query.name
            let res = this.carList.some(function (item) {
                return item == itemName

            })
            if (res) {
                this.inCar = true
                res = true
                return
            }
        }
    },

    mounted() {
        new Swiper(".swiper-container-category", {
            slidesPerView: 1,
            paginationClickable: true,
            pagination: '.swiper-pagination',
            spaceBetween: 0,
            observer: true,
            observerParents: true,
            loop: true,
        });
    }, created() {
        this.$store.commit('change', false)//进来的时候改变组件显示状态
        this.getTopGame()//获取游戏详情列表，用来显示游戏信息
        this.checkInCar()//马上查看是否存在购物车里面
    }
}
</script>